const p1 = new Promise((resolve, reject) => {
  setTimeout(() => resolve(100), 3000)
})

const p2 = new Promise((resolve, reject) => {
  setTimeout(() => resolve(200), 5000)
})
async function f () {
  console.log('开始执行f')
  var a = await p1
  console.log('p1完成了')
  var b = await p2
  console.log('p2完成了')
  return a + b
}

console.log('主函数运行...')
const res = f()
console.log('f()完成，返回值是', res)
res.then(res => { console.log(res) })

// async function f () {
//   // var a = await 1
//   // var b = await new Promise((resolve, reject) => { resolve(1) })
//   // console.log(a) // 1
//   // console.log(b) // 1
//   return await 1
// }
// const res = f()
// console.log(res.then(res => { console.log(res) }))

// function f1 () {
//   return 1
// }
// async function f2 () {
//   return 1
// }
// async function f3 () {}
// const r1 = f1()
// const r2 = f2()
// const r3 = f3()
// console.log(r1) // 1
// console.log(r2) // Promise, resolved(1)
// console.log(r3) // Promise, resolved(undefined)
// r2.then(res => { console.log(res) })
// r3.then(res => { console.log(res) })
